home *** CD-ROM | disk | FTP | other *** search
- Path: tera.mcom.com!usenet
- From: Daniel Malmer <malmer@netscape.com>
- Newsgroups: comp.lang.c
- Subject: Re: ?? How to dump text files to screen ?? - Showit.c [01/01]
- Date: Fri, 22 Mar 1996 13:56:10 -0800
- Organization: Netscape Communications Corporation
- Message-ID: <315321FA.35A4@netscape.com>
- References: <31430CE8.469E@aol2.com> <4iddva$aic@sue.cc.uregina.ca> <314A70FF.4EC8@hsc.unt.edu> <4iocgq$kep@kryten.awinc.com>
- NNTP-Posting-Host: hobees.mcom.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.5 sun4u)
-
- Gregory Scratchley wrote:
- >
- > In article <314A70FF.4EC8@hsc.unt.edu>, Steve Fogoros <sfogoros@hsc.unt.edu>
- > wrote:
- > >Tristan Psionic wrote:
- > >TP>
- > >TP> In <31430CE8.469E@aol2.com>, Neil <neil@aol2.com> writes:
- > >TP> >I need help -- how can I open up a text file and just dump it
- > >TP> >all out (in plain text) to the screen?
- >
-
- How about:
-
- #include <stdio.h>
- #include <errno.h>
-
- int
- main(int argc, char* argv[])
- {
- FILE* input_file;
- char buf[1024];
-
- if ( argc != 2 ) {
- fprintf(stderr, "Usage: '%s filename'\n", argv[0]);
- exit(1);
- }
-
- if ( (input_file = fopen(argv[1], "r")) == NULL ) {
- perror(argv[1]);
- exit(errno);
- }
-
- while ( fgets(buf, sizeof(buf), input_file) ) {
- fputs(buf, stdout);
- }
-
- return 0;
- }
-
- If you're on a Unix box, you can just use the "cat" command.
-
- Dan
- --
- Daniel Malmer
- Netscape Communications Corporation
- malmer@netscape.com - http://home.netscape.com/people/malmer/
- Any opinions expressed above are mine.
-